#import "MapAppAppDelegate.h"
#import "MapViewController.h"

/**
 * Initializes and displays the main view controller for this application.
 * 
 * @author      Justin Hollander
 * @author      James Lin
 * @version     1.0.2 
 * @since       0.1.0
 */
@implementation MapAppAppDelegate

@synthesize window;
@synthesize mapViewController;
@synthesize navigationController;

/**
 * Initializes basic UIWindow with main components then sets to visible.
 *
 * This is all done programically without the use of nibs.
 *
 * @param application  the application that has just launched
 */
- (void)applicationDidFinishLaunching:(UIApplication*)application {
	mapViewController = [[MapViewController alloc] init];
	PinNoteManager* pnm = [PinNoteManager sharedPinNoteManager];
	FoursquareManager* fsm = [FoursquareManager sharedFoursquareManager];
	
	NSArray* delegates = [NSArray arrayWithObjects:pnm, fsm, nil];
	
	window = [[TouchableWindow alloc] initWithView:mapViewController.view 
										 delegates:delegates];
	navigationController = [[UINavigationController alloc] initWithRootViewController:mapViewController];
	
	[window addSubview:navigationController.view];
    [window makeKeyAndVisible];
}

/**
 * Deallocate the application.
 */
- (void)dealloc {
	[[PinNoteManager sharedPinNoteManager] dealloc];
	[[FoursquareManager sharedFoursquareManager] dealloc];
	[[BusDirectoryManager sharedBusDirectoryManager] dealloc];
	[[EventManager sharedEventManager] dealloc];
	[mapViewController release], mapViewController = nil;
	[navigationController release], navigationController = nil;
    [window release], window = nil;
    [super dealloc];
}

@end